<template>
  <div class="recommend">
    <a class="recommend-item" href="javascript:"
       v-for="(item, index) in recommends.slice(0, 4)"
       :key="item.id"
       :title="item.title"
       @click.prevent="goD(item.id)">
      <img v-lazy="item.cover_url" :alt="item.title">
      <div>{{ item.title }}</div>
    </a>
  </div>
</template>

<script>
import {useRouter} from 'vue-router'

export default {
  name: "RecommendView",
  props: {
    recommends: {
      type: Array,
      default() {
        return []
      }
    }
  },
  setup() {
    const router = useRouter()
    const goD = id => router.push({
      name: 'Detail',
      params: {
        id
      }
    })

    return {
      goD
    }
  }
}
</script>

<style scoped lang="scss">
.recommend {
  display: flex;
  justify-content: space-around;
  padding: 15px 0;
  border-bottom: 3px solid #f6f6f6;

  .recommend-item {
    flex-basis: 20%;
    font-size: 14px;
    color: var(--color-text);
    text-align: center;
  }
}
</style>